﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;

namespace BoardPACDSBO.UserMgt
{
    public static class DropdownListGenrator
    {
        public static IEnumerable<T> EnumToList<T>()
        {
            Type enumType = typeof(T);

            if (enumType.BaseType != typeof(Enum))
                throw new ArgumentException("T must be of type System.Enum");

            Array enumValArray = Enum.GetValues(enumType);
            List<T> enumValList = new List<T>(enumValArray.Length);

            foreach (int val in enumValArray)
            {
                enumValList.Add((T)Enum.Parse(enumType, val.ToString()));
            }
            return enumValList;
        }

        public static string GetEnumDescription(Enum value)
        {
            FieldInfo fi = value.GetType().GetField(value.ToString());

            DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);

            if (attributes != null &&
                attributes.Length > 0)
                return attributes[0].Description;
            else
                return value.ToString();
        }
    }

    [MetadataType(typeof(UserMgtModelsMetadata))]
    public partial class UserMgtModels
    {
    }

    public class UserMgtModelsMetadata
    {
        public int customUserId { get; set; }
        public string username { get; set; }
        public string firstName { get; set; }
        public string lastname { get; set; }
        public string displayName { get; set; }
        public byte userStatus { get; set; }
        public string officeEmail { get; set; }
        [Required]
        public string email { get; set; }
        public string officeno { get; set; }
        public string mobileno { get; set; }
        public string roleName { get; set; }
        public string saluation { get; set; }
        public string imagePath { get; set; }
        public int modifiedBy { get; set; }

        public bool isLocked { get; set; }
        public bool passwordReseted { get; set; }

        public override string ToString()
        {
            return " " + this.customUserId + " " + this.username + " " + this.firstName + ""
                + this.lastname + " " + this.email + " " + this.officeno + " " + this.mobileno + " " + this.userStatus + " " + this.officeEmail + " " + this.roleName;
        }

        
    }


    public class RoleManagementMetaData
    {
        public Guid RoleId { get; set; }
        public string RoleName { get; set; }
        public string Description { get; set; }
        
        public override string ToString()
        {
            return " " + this.RoleName + " " + this.Description + " ";
        }
    }

    public class EditUser
    {
        public int customUserId { get; set; }
        public string username { get; set; }
        public string firstName { get; set; }
        public string lastname { get; set; }
        public string displayName { get; set; }
        public string jobTitle{ get; set; }
        public string saluation { get; set; }
        public string companyName{ get; set; }
        public string companyAddress{ get; set; }
        public string skypeId{ get; set; }
        public string facebook{ get; set; }
        public string linkedIn{ get; set; }
        public string description{ get; set; }
        public string officeEmail { get; set; }
        [Required]
        public string email { get; set; }
        public string officeno { get; set; }
        public string mobileno { get; set; }
        public string roleName { get; set; }
        public string imagePath { get; set; }

        public override string ToString()
        {
            return " " + this.customUserId + " " + this.username + " " + this.firstName + ""
                + this.lastname + " " + this.jobTitle + " " + this.companyName + " " + this.companyAddress
                + "" + this.skypeId + " " + this.facebook + " " + this.linkedIn + " " + this.description + " " + this.email + " " + this.officeEmail
                + " " + this.officeno + " " + this.mobileno + " " + this.roleName + " " + this.imagePath;
        }
    }
}